package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {


    /**
     * 根据id菜品名称查询所属id
     * @param ids
     * @return
     */
    List<Long> getSetMealByDishId(List<Long> ids);

    /**
     * 新增套餐里的菜品
     * @param setmealDishes
     */
    void saveSetmealDish(List<SetmealDish> setmealDishes);

    /**
     * 从套餐里删除菜品
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{setmealId}")
    void deleteDishFromSetMeal(Long setmealId);

    /**
     * 根据套餐id查询里面的菜品
     * @param id
     * @return
     */

    List<SetmealDish> findDishesBysetmealId(Long id);

    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getDishBysetmealId(Long id);
}

